(function($){
	
    $(function(){
    	
    	//搜索条件 单选框和活动名称二选一
    	$('#s_active_name').blur(function(){
    		if ($(this).val().replace(/(^\s*)|(\s*$)/g, '') !== ''){
    			$('#s_active_state').attr('disabled',true);
    		}else{
    			$('#s_active_state').attr('disabled',false);
    		}
    	});
    	
    	$('#s_active_state').change(function(){
    		if ($(this).val() !== '0') {
    			$('#s_active_name').val('').attr('disabled',true);
    		}else{
    			$('#s_active_name').attr('disabled',false);
    		}
    	});
    	
    	//日期时间控件
		$('.datepicker')[0] && $('.datepicker').datepicker();
		//$('.timepicker')[0] && $('.timepicker').ptTimeSelect();
		
		//submit
		$('#btn_search').click(function(){
			var form = $('#search_form');
			$.browser.msie && clearPlaceholder(form);
			if(form.validate(VALIDATE.searchStattistics).form()) {
				$('#s_type').val('');
				form.submit();
			}
		});
		
		$('#s_active_state').change(function(){
			var form = $('#search_form');
			$.browser.msie && clearPlaceholder(form);
			if(form.validate(VALIDATE.searchStattistics).form()) {
				$('#s_type').val('');
				form.submit();
			}
		});
		
		//详细页面
		$('.detail').click(function(){
			var form = $('#search_form');
			//详细页面查询
			$('#s_type').val('detail');
			$('#s_id').val($(this).attr('id'));
			$('#s_active_name').val($(this).text());
			//form.attr('action',ctx+'/statistics/detail.do');
			form.submit();
		});
		
		$('.total').click(function(){
			var form = $('#search_form');
			//详细页面查询
			$('#s_type').val('total');
			//form.attr('action',ctx+'/statistics/detail.do');
			form.submit();
		});
    })
    
})(jQuery);